﻿

using System.Web.UI;
using System.IO;
using System.Web;

namespace Omes.Web.FrameWork
{
    /// <summary>
    /// 重写HtmlTextWriter
    /// </summary>
    public class RewriterFormHtmlTextWriter : HtmlTextWriter
    {
        #region 构造
        public RewriterFormHtmlTextWriter(HtmlTextWriter writer)
            : base(writer)
        {
            this.InnerWriter = writer.InnerWriter;
        }

        public RewriterFormHtmlTextWriter(TextWriter writer)
            : base(writer)
        {
            this.InnerWriter = InnerWriter;
        }
        #endregion

        #region 重写方法
        public override void WriteAttribute(string name, string value, bool fEncode)
        {
            if (name == "action")
            {
                HttpContext context = HttpContext.Current;
                if (context.Items["ActionAlreadyWritten"] == null)
                {
                    value = context.Request.RawUrl;
                    context.Items["ActionAlreadyWritten"] = true;
                }
            }
            base.WriteAttribute(name, value, fEncode);
        }
        #endregion
    }
}
